<?php

namespace App\Kuafu\Order\Enum;

class CodeEnum
{
    public const SOURCE_TYPE_SHOP   = 1; // 门店堂食订单
    public const SOURCE_TYPE_WAIMAI = 2; // 外卖订单

    // 订单来源 1 pos 2微信小程序 3美团外卖 4饿了么
    public const SOURCE_TYPE_POS                   = 1;
    public const SOURCE_TYPE_MINI                  = 2;
    public const SOURCE_TYPE_MT                    = 3;
    public const SOURCE_TYPE_ELM                   = 4;
    public const SOURCE_TYPE_DY                    = 5;
    public const SOURCE_TYPE_DY_MINI               = 6;
    public const SOURCE_TYPE_MERCHANT_CHECK_COUPON = 7;

    public const SOURCE_TYPES = [
        self::SOURCE_TYPE_POS                   => 'POS',
        self::SOURCE_TYPE_MINI                  => '微信小程序',
        self::SOURCE_TYPE_MT                    => '美团',
        self::SOURCE_TYPE_ELM                   => '饿了么',
        self::SOURCE_TYPE_DY                    => '抖音外卖',
        self::SOURCE_TYPE_DY_MINI               => '抖音小程序',
        self::SOURCE_TYPE_MERCHANT_CHECK_COUPON => '商家核销三方券',
    ];

    public const THIRD_ORDER_SOURCE_DY = 1;

    public const THIRD_ORDER_SOURCE_TEXT = [
        self::THIRD_ORDER_SOURCE_DY => '抖音',
    ];

    // 订单来源 - 区分店内、外卖
    public const SOURCE_TYPE_IN  = [
        self::SOURCE_TYPE_POS,
        self::SOURCE_TYPE_MINI,
        self::SOURCE_TYPE_DY_MINI,
        self::SOURCE_TYPE_MERCHANT_CHECK_COUPON,
    ]; // 店内
    public const SOURCE_TYPE_OUT = [self::SOURCE_TYPE_MT, self::SOURCE_TYPE_ELM, self::SOURCE_TYPE_DY];   // 外卖

    // 折扣类型
    public const PRODUCTION_DISCOUNT_TYPE_COUNT = 1; // 折扣
    public const PRODUCTION_DISCOUNT_TYPE_ANNUL = 2; // 减免

    // 整单折扣类型
    public const ORDER_DISCOUNT_TYPE_NO         = 0; // 无优惠
    public const ORDER_DISCOUNT_TYPE_COUNT      = 1; // 折扣
    public const ORDER_DISCOUNT_TYPE_ANNUL      = 2; // 减免
    public const ORDER_DISCOUNT_TYPE_CUSTOM_PAY = 3; // 自定义优惠的优惠金额

    public const ORDER_PAY_ACTION_DEFAULT    = 0; // 默认
    public const ORDER_PAY_ACTION_INITIATIVE = 1; // 用户主扫
    public const ORDER_PAY_ACTION_PASSIVITY  = 2; // 用户被扫

    public const ORDER_LEADING_ZERO = 4;// 订单流水号长度，例如0001

    public const ORDER_PAY_ACTION = [
        self::ORDER_PAY_ACTION_DEFAULT,
        self::ORDER_PAY_ACTION_INITIATIVE,
        self::ORDER_PAY_ACTION_PASSIVITY
    ];

    public const ORDER_PAY_ACTION_TEXTS = [
        self::ORDER_PAY_ACTION_DEFAULT    => '默认',
        self::ORDER_PAY_ACTION_INITIATIVE => '用户主扫',
        self::ORDER_PAY_ACTION_PASSIVITY  => '用户被扫',
    ];

    public const ORDER_PAY_CHANNEL_TRY_DEFAULT  = 0;     // 默认
    public const ORDER_PAY_CHANNEL_ALIPAY       = 1;     // 支付宝
    public const ORDER_PAY_CHANNEL_WECHAT       = 2;     // 微信
    public const ORDER_PAY_CHANNEL_MONEY        = 3;     // 现金支付
    public const ORDER_PAY_CHANNEL_WECHAT_MINI  = 4;     // 微信小程序
    public const ORDER_PAY_CHANNEL_UNION_PAY    = 5;     // 云闪付
    public const ORDER_PAY_CHANNEL_ZERO_PAY     = 100;   // 结清 [无金额支付结账(0元)]
    public const ORDER_PAY_CHANNEL_TRY_TACK     = 101;   // 试吃
    public const ORDER_PAY_CHANNEL_OFFICE_MONEY = 102;   // 离线支付
    public const ORDER_PAY_CHANNEL_MA_LING      = 103;   // 抹零

    public const ORDER_PAY_CHANNEL = [
        self::ORDER_PAY_CHANNEL_ALIPAY,
        self::ORDER_PAY_CHANNEL_WECHAT,
        self::ORDER_PAY_CHANNEL_MONEY,
        self::ORDER_PAY_CHANNEL_TRY_TACK,
        self::ORDER_PAY_CHANNEL_OFFICE_MONEY,
        self::ORDER_PAY_CHANNEL_WECHAT_MINI,
        self::ORDER_PAY_CHANNEL_ZERO_PAY,
        self::ORDER_PAY_CHANNEL_MA_LING,

    ];

    //支付渠道
    public const CHANNEL_CODE_TEXT = [
        self::ORDER_PAY_CHANNEL_TRY_DEFAULT  => '-',
        self::ORDER_PAY_CHANNEL_ALIPAY       => '支付宝',
        self::ORDER_PAY_CHANNEL_WECHAT       => '微信',
        self::ORDER_PAY_CHANNEL_MONEY        => '现金支付',
        self::ORDER_PAY_CHANNEL_TRY_TACK     => '试吃',
        self::ORDER_PAY_CHANNEL_OFFICE_MONEY => '离线支付',
        self::ORDER_PAY_CHANNEL_WECHAT_MINI  => '微信小程序',
        self::ORDER_PAY_CHANNEL_ZERO_PAY     => '结清',
        self::ORDER_PAY_CHANNEL_MA_LING      => '抹零',
        self::ORDER_PAY_CHANNEL_UNION_PAY    => '银联云闪付',
    ];

    // 支付场景
    public const ORDER_PAY_EVENT_ORDER  = 1;  // 下单场景
    public const ORDER_PAY_EVENT_REFUND = 2;  // 反结账场景

    // 订单状态
    public const ORDER_STATUS_WAIT_PAY         = 0;  // 待支付
    public const ORDER_STATUS_WAIT_MARK        = 1;  // 待制作
    public const ORDER_STATUS_WAIT_TACK        = 2;  // 待取餐
    public const ORDER_STATUS_FINISHED         = 3;  // 已完成
    public const ORDER_STATUS_CANCEL           = 9;  // 已取消
    public const ORDER_STATUS_REVERSE          = 10; // 反结账待支付
    public const ORDER_STATUS_CHECK_EXT_COUPON = 11; // 美团-优惠券-已核销, 订单待支付 [没用起来]

    //订单状态
    public const STATUS_CODE_TEXT = [
        self::ORDER_STATUS_WAIT_PAY         => "待支付",
        self::ORDER_STATUS_WAIT_MARK        => "待制作",
        self::ORDER_STATUS_WAIT_TACK        => "待取餐",
        self::ORDER_STATUS_FINISHED         => "已完成",
        self::ORDER_STATUS_CANCEL           => "已取消",
        self::ORDER_STATUS_REVERSE          => '待支付(反)',
        self::ORDER_STATUS_CHECK_EXT_COUPON => '待支付'
    ];


    public const ORDER_CANCEL_TIME_MINUS = 15; // 订单 x 分钟后自动取消
    // 订单支付状态
    public const ORDER_PAY_STATUS_WAIT    = 0; // 待支付
    public const ORDER_PAY_STATUS_PAYED   = 1; // 已支付
    public const ORDER_PAY_STATUS_CANCEL  = 2; // 已取消
    public const ORDER_PAY_STATUS_REVERSE = 3; // 反结账待支付
    public const ORDER_PAY_STATUS_PAYING  = 9; // 支付中

    public const ORDER_PAY_STATUSES = [
        self::ORDER_PAY_STATUS_WAIT    => '待支付',
        self::ORDER_PAY_STATUS_PAYED   => '已支付',
        self::ORDER_PAY_STATUS_CANCEL  => '已取消',
        self::ORDER_PAY_STATUS_REVERSE => '反结账待支付',
        self::ORDER_PAY_STATUS_PAYING  => '支付中',
    ];

    // 订单退款状态
    public const ORDER_REFUND_STATUS_DEFAULT = 0;
    public const ORDER_REFUND_STATUS_PART    = 1;
    public const ORDER_REFUND_STATUS_ALL     = 2;

    public const REFUND_STATUS = [
        self::ORDER_REFUND_STATUS_DEFAULT,
        self::ORDER_REFUND_STATUS_PART,
        self::ORDER_REFUND_STATUS_ALL,
    ];

    //反结账
    public const REFUND_CODE_TEXT = [
        self::ORDER_REFUND_STATUS_DEFAULT => '无退款',
        self::ORDER_REFUND_STATUS_PART    => '部分退款',
        self::ORDER_REFUND_STATUS_ALL     => '全部退款',
    ];


    //折扣类型
    public const DISCOUNT_TYPE_TEXT = [
        self::ORDER_DISCOUNT_TYPE_NO         => '无优惠',
        self::ORDER_DISCOUNT_TYPE_COUNT      => '折扣',
        self::ORDER_DISCOUNT_TYPE_ANNUL      => '减免',
        self::ORDER_DISCOUNT_TYPE_CUSTOM_PAY => '自定义支付',
    ];


    // 取整方式
    public const ORDER_INTER_METHOD_DEFAULT = 0; // 四舍五入
    public const ORDER_INTER_METHOD_FLOOR   = 1; // 向下取整
    public const ORDER_INTER_METHOD_CEIL    = 2; // 向上取整

    // 订单状态
    public const ORDER_IS_ONLINE_ONLINE  = 0; // 在线订单
    public const ORDER_IS_ONLINE_OFFLINE = 1; // 离线订单

    // 支付类型
    public const ORDER_PAYMENT_TYPE_FIAT           = 1; // 法币[支付微信等]
    public const ORDER_PAYMENT_TYPE_CUSTOM_PAYMENT = 2; // 自定义支付

    public const ORDER_EXTERNAL_TYPE_TEXT = [
        self::ORDER_EXTERNAL_TYPE_COUPON_PACKAGE => '券包'
    ];

    public const ORDER_EXTERNAL_TYPE_COUPON_PACKAGE   = 1; // 券包
    public const ORDER_EXTERNAL_TYPE_ENTITLEMENT_CARD = 2; // 权益卡
    public const ORDER_EXTERNAL_TYPE_ACTIVITY         = 3; // 活动

    // 订单上锁类型
    public const ORDER_LOCK_TYPE_ORDER_PAY        = '1'; // 支付订单锁
    public const ORDER_LOCK_TYPE_RESERVE          = '2'; // 支付订单反结账锁
    public const ORDER_LOCK_TYPE_ORDER_PAY_COMMON = '3'; // 通用支付订单上锁

    // 订单流水总长度
    public const LEADING_ZERO_LENGTH = 4;

    public const QR_CODE_ONE         = 1;
    public const QR_CODE_TWO         = 2;
    public const QR_CODE_KEY         = 'order';
    public const QR_CODE_EXPIRE_TIME = 600;
    public const QR_CODE_THREE       = 3;

    const QR_CODE_TEXT = [
        self::QR_CODE_ONE   => 'https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode',
        self::QR_CODE_TWO   => 'https://api.weixin.qq.com/wxa/getwxacode',
        self::QR_CODE_THREE => 'https://api.weixin.qq.com/wxa/getwxacodeunlimit'
    ];


    public const DELIVERY_TYPE_DEFAULT           = 0; // 默认
    public const DELIVERY_TYPE_SELF_DELIVERY     = 1; // 自配送
    public const DELIVERY_TYPE_DISTRIBUTION      = 2; // 渠道配送
    public const DELIVERY_TYPE_DISTRIBUTION_SELF = 3; // 渠道自提

    public const DELIVERY_TYPE_TEXT = [
        self::DELIVERY_TYPE_SELF_DELIVERY     => '自配送',
        self::DELIVERY_TYPE_DISTRIBUTION      => '渠道配送',
        self::DELIVERY_TYPE_DISTRIBUTION_SELF => '渠道自提',
    ];


    //订单菜品销售统计
    public const PRODUCT_SELLING_STATISTICS   = 1;
    public const CATEGORY_SELLING_STATISTICS  = 2;
    public const SELLING_STATISTICS_CHUNK_NUM = 200;

    public const SELLING_STATISTICS_CODE_TEXT = [
        self::PRODUCT_SELLING_STATISTICS  => 'productId',
        self::CATEGORY_SELLING_STATISTICS => 'categoryId',
    ];

    public const ORDER_INFO_COUPON_TYPE_PAY   = 1;//支付优惠
    public const ORDER_INFO_COUPON_TYPE_ORDER = 2;//订单优惠
    public const ORDER_INFO_PAY_TYPE_TOTAL    = 1;//支付合计
    public const ORDER_INFO_PAY_TYPE_REAL     = 2;//订单实收

    // 订单的开票状态 - 订单数据库的开票状态 [非对外的状态]

    public const ORDER_INVOICE_STATUS_DEFAULT      = 0; // 未开票
    public const ORDER_INVOICE_STATUS_WAIT         = 1; // 等待开票
    public const ORDER_INVOICE_STATUS_HAVEN        = 2; // 已开票
    public const ORDER_INVOICE_STATUS_CANCELING    = 3; // 取消开票 ing
    public const ORDER_INVOICE_STATUS_CANCELED     = 4; // 已取消
    public const ORDER_INVOICE_STATUS_RED_CANCELED = 5; // 已红冲
//    public const ORDER_INVOICE_STATUS_BANNED_CANCELED = 6; // 不能取消-超过取消次数 [仅收 pos 取消开票限制]

    // 对外开票状态
    public const ORDER_OUT_INVOICE_EXP_TIME = 30; // 30 天无法快票

    public const ORDER_OUT_INVOICE_SOURCE_DFAULT = 0; // 正常订单
    public const ORDER_OUT_INVOICE_SOURCE_NORMAL = 1; // 正常点击取消开票
    public const ORDER_OUT_INVOICE_SOURCE_REVERT = 2; // 反结账取消开票

    public const ORDER_OUT_INVOICE_STATUS_DEFAULT         = 0; // 未开票
    public const ORDER_OUT_INVOICE_STATUS_HAVEN           = 2; // 已开票
    public const ORDER_OUT_INVOICE_STATUS_CANCELING       = 3; // 取消中
    public const ORDER_OUT_INVOICE_STATUS_CANCELED        = 4; // 已取消
    public const ORDER_OUT_INVOICE_STATUS_BANNED_CANCELED = 6; // 无法取消发票
    public const ORDER_OUT_INVOICE_STATUS_CANNOT_CREATE   = 7; // 不展示开票按钮 [1. 有可能是 超过 30 天]

    public const ORDER_STATUS_DEFAULT = 0;//0-订单状态默认查询
    public const ORDER_STATUS_APPLET  = 1;//1-订单查询小程序投诉工单查询
}
